package com.yax.mickey.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yax.mickey.entity.Order;
import com.yax.mickey.service.OrderService;
import com.yax.mickey.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
* @author yax
* @description 针对表【order(订单信息表)】的数据库操作Service实现
* @createDate 2024-05-27 09:03:30
*/
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order>
    implements OrderService{

    @Autowired
    OrderMapper orderMapper;

    @Override
    public List<Order> getOrdersByUserId(Integer userId) {
        return orderMapper.getOrdersByUserId(userId);
    }

    @Override
    public Order getOrdersByOrderId(Integer orderId) {
        return orderMapper.getOrdersByOrderId(orderId);
    }

    @Override
    public Integer addOrders(Integer id) {
        Order order = new Order();
        order.setUserId(id);
        order.setOrderTime(new Date());
        order.setTotalAmount(0D);
        return orderMapper.addOrders(order);
    }

    @Override
    public void updateOrders(Order order) {
        orderMapper.updateOrders(order);
    }

    @Override
    public void deleteOrders(Order order) {
        orderMapper.deleteOrders(order);
    }
}